package com.own.business.system.user.entity.dto;

import com.own.business.system.user.entity.bo.SystemUserInfoBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * SystemUserInfoDto
 *
 * @author chenxueli
 * @date 2021/06/24 15:46:54
 */
@Schema(title = "系统用户基本信息" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemUserInfoDto extends BaseDto<SystemUserInfoBo> {

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "名称")
    private String name;

    @Schema(title = "手机号")
    private String phone;

    @Schema(title = "邮箱")
    private String email;

    @Schema(title = "性别 1=男 2=女 0=保密")
    private Integer gender;

    @Schema(title = "头像")
    private String avatar;

    @Schema(title = "介绍")
    private String introduction;

    @Schema(title = "用户类型 1=普通用户 2=管理员")
    private Integer type;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public SystemUserInfoBo toBo(SystemUserInfoBo entity) {
        if (entity == null) {
            entity = new SystemUserInfoBo();
        }
        entity.setUserId(userId);
        entity.setName(name);
        entity.setPhone(phone);
        entity.setEmail(email);
        entity.setGender(gender);
        entity.setAvatar(avatar);
        entity.setIntroduction(introduction);
        entity.setType(type);
        return super.toBo(entity);
    }

}
